#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#define MAXSIZE 100
int main()
{
    int n = 0;
    scanf("%d", &n);
    int arr[MAXSIZE];
    int i = 0;
    int count = 0;
    while (n != 0)
    {
        arr[i] = n % 6;
        i++;
        n /= 6;
        count++;
    }
    for (int i = count - 1; i >= 0; i--)
    {
        printf("%d", arr[i]);
    }

    return 0;
}